/**
 * 开发工具中页面生成处理JS
 */
$.page={
	
	getField:function(){
			
		var className = $("#className").val();
			
		if(className == ""){
				
			alertMsg.warn(igdConstant.emptyClassNameInput);

		}else{

			var url = "/dev/ajax/getClassField.action?className="+className;
				
			ajaxReq(url,function(data){
				
				$("#fields").html("");
				
				var dataSize = data.rspDataSize;
					
				var options = $.valid.createOptions();

				for(var i=0;i<dataSize;i++){

					var fieldName = data.rspData[i];
						
					$("#fields").append("<tr><td><input class=\"field\" id=\""+fieldName+"\" type=\"checkbox\" name=\"dataField\">"+fieldName+"</td><td><input id=\""+fieldName+"Required\" type=\"checkbox\"/>是否必填，校验类型：</td><td><select id=\""+fieldName+"Valid\">"+options+"</select></td></tr>");

				}
			},false);
		}
	},
	
	createPage:function(){

		var jsonArray = new Array();
		
		var className = $("#className").val();
		
		var pageType = $("input[name='pageType']:checked").val();
		
		var dataTag = $("#dataTag").val();
		
		var pageLayout = $("input[name='pageLayout']:checked").val();
		
		var pageOpenType = $("input[name=''pageOpenType]:checked").val();
		
		$(".field").each(function(){
			
			var $this = $(this);
			
			if($this.attr("checked")=="checked"){
				
				var fieldName = $this.attr("id");
				
				var isrequired = false;
				
				if($("#"+fieldName+"Required").attr("checked") == "checked"){
					
					isrequired = true;
					
				}else{
					
					isrequired = false;
					
				}
				
				var validType = $("#"+fieldName+"Valid").val();
				
				var json = "{fieldName:\""+fieldName+"\",isRequired:\""+isrequired+"\",validType:\""+validType+"\"}";
				
				jsonArray.push(json);

			}
		});
		
		var param = "{className:\""+className+"\",pageType:\""+pageType+"\",dataTag:\""+dataTag+"\",pageLayout:\""+pageLayout+"\",pageOpenType:\""+pageOpenType+"\",fieldJson:["+jsonArray.join(",")+"]}";
		
		var url = "/dev/ajax/createPage.action?pageInfo="+param;
		
		getRspText(url,function(data){
			
			$("#pageText").val(data);
			
		},false);
	}
};